<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><fmt:message code="doc.th.AttendancePson" /></title>
    <link rel="stylesheet" href="/css/supervise/statistic.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" 	src="/js/base/tablePage.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <style>
        .queryConditon input{
            width:100px;
        }
        .pagediv table tr th{
            /*border-right: 1px solid #c0c0c0;*/
            font-size: 13pt;
        }
        .title{
            font-size: 18px;
            line-height: 30px;
            font-weight: bold;
        }
        #back{
            background: #00a0e9;
            margin-left: 10px;
            padding: 5px 1px;
            border-radius: 5px;
            color: #fff;
            cursor: pointer;
            width: 60px;
            text-align: center;
            float: right;

            margin:20px 20px;
        }
        .title{
            font-weight: normal;
            display: inline-block;
            font-size: 22px;
            color: #494d59;
            vertical-align: middle;
            margin-left: 10px;
            line-height: 51px;
        }
    </style>
</head>
<body>
<!--标题导航结束-->
<div style="width: 100%;text-align: right">
    <div id="back">返回</div>
</div>

<div class="main">

    <div class="tableOne">
        <div class="title">
            上下班查询结果
        </div>
        <div>
            <table>
                <thead>
                    <tr>
                        <th>类型</th>
                        <th>日期</th>
                        <th>星期</th>
                        <th>时间</th>
                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableTwo">
        <div class="title">
            外出记录查询结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>申请时间</th>
                    <th>外出时间</th>
                    <th>归来时间</th>
                    <th>外出原因</th>
                    <th>审批人员</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableThree">
        <div class="title">
            出差记录询结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>出差地点</th>
                    <th>出差内容</th>
                    <th>审批时间</th>
                    <th>审批人员</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableFour">
        <div class="title">
            请假记录查询结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>请假类型</th>
                    <th>占年休假</th>
                    <th>占倒休假</th>
                    <th>请假原因</th>
                    <th>审批时间</th>
                    <th>审批人员</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableFive">
        <div class="title">
            加班记录询结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>加班时长</th>
                    <th>加班内容</th>
                    <th>审批内容</th>
                    <th>审批时间</th>
                    <th>审批人员</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableSix">
        <div class="title">
            外勤记录查询结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>外勤时间</th>
                    <th>外勤地点</th>
                    <th>外勤内容</th>
                    <th>附件</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
    <div class="tableSeven">
        <div class="title">
            异常说明结果
        </div>
        <div>
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>班次</th>
                    <th>申诉类型</th>
                    <th>申诉登记时间</th>
                    <th>异常时间</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
</div>

<script>
    function check(name){
        if(name == undefined){
            return ''
        }else{
            return name;
        }
    }

    var ajaxPage={

        data:{
            page:1,//当前处于第几页
            pageSize:5,//一页显示几条
            uesFlag:true,
            uid:$.GetRequest().uid,
            beginDate:$.GetRequest().beginDate,
            endDate:$.GetRequest().endDate,
        },
        page:function(){
            var me=this;
            $.ajax({  //列表数据展示
                type:'post',
                url:'/attend/findAttendList2',
                dataType:'json',
                data:me.data,
                success:function(res){
                    var data=res.data[0];

                    var shangxiaban = data.shangxiabanchaxun;
                    var waichu = data.waichuxiangqing;
                    var chuchai = data.chuchaixiangqing;
                    var qingjia = data.qingjiaxiangqing;
                    var jiaban = data.jiabanxiangqing;
                    var waiqin = data.waiqinList;
                    var yichang = data.shebeiyichangList;

                    var str1 = "" //上下班结果
                    if(shangxiaban.length>0){
                        for(var i=0;i<shangxiaban.length;i++){
                            if(shangxiaban[i].length>0){
                                for(var j = 0;j<shangxiaban[i].length;j++){
                                    str1+= ' <tr>\n' +
                                        '                        <td>'+check(shangxiaban[i][j].type)+'</td>\n' +
                                        '                        <td>'+check(shangxiaban[i][j].date)+'</td>\n' +
                                        '                        <td>'+check(shangxiaban[i][j].week)+'</td>\n' +
                                        '                        <td>'+check(shangxiaban[i][j].time)+'</td>\n' +
                                        '                    </tr>'
                                }
                            }
                        }
                        $('.tableOne tbody').html(str1)
                    }else{
                        str1+= ' <tr>\n' +
                            '                        <td colspan="4">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableOne tbody').html(str1)
                    }

                    var str2 = "";//外出
                    if(waichu.length>0){
                        for(var i = 0;i<waichu.length;i++){
                            str2 += '<tr>\n' +
                                '                    <td>'+check(waichu[i].userName)+'</td>\n' +
                                '                    <td>'+check(waichu[i].submitTime)+'</td>\n' +
                                '                    <td>'+check(waichu[i].outTime1)+'</td>\n' +
                                '                    <td>'+check(waichu[i].outTime2)+'</td>\n' +
                                '                    <td>'+check(waichu[i].outType)+'</td>\n' +
                                '                    <td>'+check(waichu[i].leaderName)+'</td>\n' +
                                '                    <td>'+function(){
                                if(waichu[i].status == '0'){
                                    return '未确认'
                                }else{
                                    return '确认归来'
                                }
                                }()+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableTwo tbody').html(str2)
                    }else{
                        str2+= ' <tr>\n' +
                            '                        <td colspan="7">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableTwo tbody').html(str2)
                    }


                    var str3 = ""; //出差
                    if(chuchai.length>0){
                        for(var i = 0;i<chuchai.length;i++){
                            str3 += '<tr>\n' +
                                '                    <td>'+check(chuchai[i].userName)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].evectionDate1)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].evectionDate2)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].evectionDest)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].reason)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].handleTime)+'</td>\n' +
                                '                    <td>'+check(chuchai[i].leaderName)+'</td>\n' +
                                '                    <td>'+function(){
                                    if(chuchai[i].allow == '0'){
                                        return '待审批'
                                    }else if(chuchai[i].allow == '1'){
                                        return '已批准'
                                    }else{
                                        return '未批准'
                                    }
                                }()+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableThree tbody').html(str3)
                    }else{
                        str3+= ' <tr>\n' +
                            '                        <td colspan="8">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableThree tbody').html(str3)
                    }


                    var str4 = ""; //请假
                    if(qingjia.length>0){
                        for(var i = 0;i<qingjia.length;i++){
                            str4 += '<tr>\n' +
                                '                    <td>'+check(qingjia[i].userName)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].leaveDate1)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].leaveDate2)+'</td>\n' +
                                '                    <td>'+function(){
                                if(qingjia[i].leaveType2 == '1'){
                                    return '事假'
                                }else if(qingjia[i].leaveType2 == '2'){
                                    return '病假'
                                }else if(qingjia[i].leaveType2 == '3'){
                                    return '年假'
                                }else{
                                    return '其他'
                                }
                                }()+'</td>\n' +
                                '                    <td>'+check(qingjia[i].annualLeave)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].leaveType)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].leaveType)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].handleTime)+'</td>\n' +
                                '                    <td>'+check(qingjia[i].leaderName)+'</td>\n' +
                                '                    <td>'+function(){
                                    if(qingjia[i].status == '1'){
                                        return '未确认'
                                    }else if(qingjia[i].status == '2'){
                                        return '确认销假'
                                    }
                                }()+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableFour tbody').html(str4)
                    }else{
                        str4+= ' <tr>\n' +
                            '                        <td colspan="10">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableFour tbody').html(str4)
                    }


                    var str5 = ""; //加班
                    if(jiaban.length>0){
                        for(var i = 0;i<jiaban.length;i++){
                            str5 += '<tr>\n' +
                                '                    <td>'+check(jiaban[i].userName)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].startTime)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].endTime)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].overtimeHours)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].overtimeContent)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].confirmView)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].reason)+'</td>\n' +
                                '                    <td>'+check(jiaban[i].handleTime)+'</td>\n' +
                                '                    <td>'+function(){
                                    if(jiaban[i].allow == '0'){
                                        return '待审批'
                                    }else if(jiaban[i].allow == '1'){
                                        return '已批准'
                                    }else if(jiaban[i].allow == '2'){
                                        return '未批准'
                                    }else{
                                        return '待确认'
                                    }
                                }()+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableFive tbody').html(str5)
                    }else{
                        str5+= ' <tr>\n' +
                            '                        <td colspan="9">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableFive tbody').html(str5)
                    }


                    var str6 = ""; //外勤
                    if(waiqin.length>0){
                        for(var i = 0;i<waiqin.length;i++){
                            str6 += '<tr>\n' +
                                '                    <td>'+check(waiqin[i].userName)+'</td>\n' +
                                '                    <td>'+function(){
                                if(waiqin[i].atime !=""&&waiqin[i].atime!=undefined){
                                    return new Date((waiqin[i].atime)*1000).Format('yyyy-MM-dd')
                                }else{
                                    return ''
                                }
                                }()+'</td>\n' +
                                '                    <td>'+check(waiqin[i].address)+'</td>\n' +
                                '                    <td>'+check(waiqin[i].remark)+'</td>\n' +
                                '                    <td>'+check(waiqin[i].fileName)+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableSix tbody').html(str6)
                    }else{
                        str6+= ' <tr>\n' +
                            '                        <td colspan="5">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableSix tbody').html(str6)
                    }

                    var str7= ""; //异常
                    if(yichang.length>0){
                        for(var i = 0;i<yichang.length;i++){
                            str7 += '<tr>\n' +
                                '                    <td>'+check(data.userName)+'</td>\n' +
                                '                    <td></td>\n' +
                                '                    <td></td>\n' +
                                '                    <td></td>\n' +
                                '                    <td>'+check(yichang[i].atime)+'</td>\n' +
                                '                </tr>'
                        }
                        $('.tableSeven tbody').html(str7)
                    }else{
                        str7+= ' <tr>\n' +
                            '                        <td colspan="5">暂无数据</td>\n' +
                            '                    </tr>'
                        $('.tableSeven tbody').html(str7)
                    }




                    //me.pageTwo(json.total,me.data.pageSize,me.data.page)
                }
            })
        },
        init:function(){
            var deptId=$('#bumen').find("option:selected").attr('deptId');
            $.ajax({//部门选择
                type:'get',
                url: '../../department/getAlldept',
                // data:deptId,
                dataType:'json',
                success:function(res){

                    var data=res.obj;
                    var src ='<option value=""><fmt:message code="hr.th.PleaseSelect" /></option>';
                    for(var i=0;i<data.length;i++){
                        src+='<option value='+data[i].deptId+'>'+data[i].deptName+'</option>'
                    }
                    $('#bumen').html(src)
                }
            });
            $('#bumen').change(function(){
                var deptid=$(this).find("option:selected").attr('deptId');
                var deptId={deptId:deptid}
                $.ajax({//人员展示
                    type:'get',
                    url: '/user/getuserNameByDeptId',
                    data:deptId,
                    dataType:'json',
                    success:function(res){
                        var data=res.obj;
                        var src ='';
                        for(var i=0;i<data.length;i++){
                            src+='<option uid='+data[i].uid+'>'+data[i].userName+'</option>'
                        }
                        $('.all').after(src)
                    }
                })
            });
            $.ajax({  //列表数据展示
                type:'get',
                url:'/attendSet/selsectAttendSet',
                dataType:'json',
                success:function(res){
                    var data=res.data
                    var attRes
                    $.each(data,function (i, item) {
                        attRes+='<option value='+item.sid+'>'+item.title+'</option>'
                    })
                    $("#attendance").append(attRes);
                }
            })
        },
        pageTwo:function (totalData, pageSize,indexs) {//设置分页
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.page=index.getCurrent();
                    mes.page();
                }
            });
        }
    };
    ajaxPage.page();
    $('#back').click(function(){
        window.location.href="/attendPage/personnelStatistics"
    })





</script>
</body>
</html>
